// import common from './common.js'
new Vue({
    el: '#app',
    data: {
        username: '',
        password: ''
    },
    async mounted() {
        let token = window.localStorage.getItem('token');
        if (token) {
            let isLogin = await getInfo()
            if (isLogin) {
                location.href = '/list.html'
            } else {
                window.localStorage.removeItem('token')
            }
            console.log(isLogin)
        }
    },
    methods: {
        sub() {
            if (this.username && this.password) {
                axios.get('/user/login', {
                    params: {
                        username: this.username,
                        password: this.password
                    }
                }).then(({data}) => {
                    if (data.success) {
                        window.localStorage.setItem('token', data.data)
                        location.href = '/list.html'
                    } else {
                        alert(data.msg)
                    }
                });
            } else {
                alert('请完善表单')
            }
        }
    }
})